﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ManageScreens : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!Page.IsPostBack)
            {
                sel_tour.DataSource = Tournament.getAvailableTournaments();
                sel_tour.DataTextField = "Tournament_Name";
                sel_tour.DataValueField = "Pk_Tournament";
                sel_tour.DataBind();
            }
        }
        catch (Exception Ex) {
            string Error = Ex.ToString(); 
        } 
    }
    
    //Set Screen
    protected void Button1_ServerClick(object sender, EventArgs e)
    {
        try
        {
            ScreenContent oScreenContent = new ScreenContent((ScreenContent.ScreenContentsType)(Int16.Parse(Select2.Items[Select2.SelectedIndex].Value)), int.Parse(Select1.Items[Select1.SelectedIndex].Value),int.Parse(sel_tour.SelectedValue));
            Application["Screen" + (string)Select1.Items[Select1.SelectedIndex].Value] = oScreenContent;
        }
        catch (Exception Ex) {
            string Error = Ex.ToString(); 
        }
    }
    protected void sel_tour_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void Select1_SelectedIndexChanged(object sender, EventArgs e)
    {
        //Verificamos si está seleccionada
        if (Application["Screen" + Select1.Items[Select1.SelectedIndex].Value] != null)
        {
            ScreenContent oScreenContent = (ScreenContent)Application["Screen" + Select1.Items[Select1.SelectedIndex].Value];
            Select2.SelectedIndex = (int)oScreenContent.oScreenContentsType;
            //sel_tour.SelectedValue = oScreenContent.PKTournament;  
        }  
    }
    protected void Select2_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}
